package cn.jeefast.modules.platform.controller;


import cn.jeefast.common.entity.MbTreatmentPlan;
import cn.jeefast.common.utils.R;
import cn.jeefast.modules.platform.service.MbTreatmentPlan1Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import cn.jeefast.common.base.BaseController;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author theodo
 * @since 2020-01-06
 */
@RestController
@RequestMapping("/mbTreatmentPlan")
@CrossOrigin
public class MbTreatmentPlan1Controller extends BaseController {
    @Autowired
	private MbTreatmentPlan1Service mbTreatmentPlanService;

    @RequestMapping("/list")
    public R list(Long projId){
        EntityWrapper  ew = new EntityWrapper();
        ew.eq("proj_id",projId);
        return R.ok().put("data",mbTreatmentPlanService.selectList(ew));
    }

    @RequestMapping("/delete")
    public R delete(Long id){
        mbTreatmentPlanService.deleteById(id);
        return R.ok();
    }

    @RequestMapping("/addOrSave")
    public R addOrSave(MbTreatmentPlan treatmentPlan){
        if(treatmentPlan.getTpId()==null){
            mbTreatmentPlanService.insert(treatmentPlan);
        }else{
            mbTreatmentPlanService.updateById(treatmentPlan);
        }
        return R.ok();
    }
}
